# 使用 Python 3.12 官方镜像[2,4](@ref)
FROM python:3.12-slim

# 阶段 1：初始化软件源
RUN echo "deb http://mirrors.aliyun.com/debian bookworm main" > /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian-security bookworm-security main" >> /etc/apt/sources.list && \
    apt-get update

# 阶段 2：安装系统依赖
RUN apt-get install -y --no-install-recommends \
    gcc libxml2-dev libxslt-dev && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# 安装Python依赖
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 复制项目代码
COPY . .

# 配置启动命令
ENTRYPOINT ["scrapy"]
CMD ["crawl", "yujinxiang", "-a", "start_page=1", "-a", "end_page=10", "-a", "url=2fMfvSXDZ5W"]